FROM centos:7

LABEL Discription="hadoop base of centos7" version="1.0"

#安装必备的软件包
RUN yum -y install net-tools
RUN yum -y install which
RUN yum -y install openssh-server openssh-clients
RUN yum -y install sudo
RUN yum clean all

#配置SSH免密登录
RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
RUN ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_ed25519_key  -N ''
RUN ssh-keygen -f /root/.ssh/id_rsa -N ''
RUN touch /root/.ssh/authorized_keys
RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
RUN echo "root:ss123456" | chpasswd
COPY ./configs/ssh_config /etc/ssh/ssh_config

#添加JDK 增加JAVA_HOME环境变量
ADD ./tools/jdk-8u212-linux-x64.tar.gz /usr/local/
ENV JAVA_HOME /usr/local/jdk1.8.0_212/
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

#添加Zookeeper并设置环境变量
ADD ./tools/apache-zookeeper-3.6.3-bin.tar.gz /usr/local
ENV ZOOKEEPER_HOME /usr/local/apache-zookeeper-3.6.3-bin

#添加flume并设置环境变量
ADD ./tools/apache-flume-1.9.0-bin.tar.gz /usr/local
ENV FLUME_HOME /usr/local/apache-flume-1.9.0-bin

#添加kafka并设置环境变量
ADD ./tools/kafka_2.13-3.1.0.tgz /usr/local
ENV KAFKA_HOME /usr/local/kafka_2.13-3.1.0

#将环境变量添加到系统变量中
ENV PATH $JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$FLUME_HOME/bin:$KAFKA_HOME/bin:$PATH

COPY ./configs/zoo.cfg $ZOOKEEPER_HOME/conf/zoo.cfg
COPY ./configs/log-kafka.properties $FLUME_HOME/conf/log-kafka.properties
COPY ./configs/server.properties $KAFKA_HOME/config/server.properties

RUN mkdir -p /data/flume/log  && \
    touch /data/flume/log/stdout.log

#开启SSH 22 端口
EXPOSE 22

#启动容器时执行的脚本文件
CMD ["/usr/sbin/sshd","-D"]
